-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the pandas.DataFrame.plot.pie docstring #20133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the code is OK. I have a specific doubt on **kwds
: optional. I would delete the asterisks and leave like kwds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the code is OK. I have a specific doubt on **kwds
: optional. I would delete the asterisks and leave like kwds
@Renton2017, could you please make a reference to a line number? |
The keyword arguments must be mentioned in the docstring as |
Can you include a screenshot of the generated html? |
Hi Dimitri, on line 2844 They cannot be true both! |
pandas/plotting/_core.py
Outdated
y : str or int, optional | ||
Label or position. | ||
If not provided, ``subplots=True`` argument must be passed. | ||
kwds : optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use **kwds : optional
, not kwds : optional
, even if the validation script complains about it.
pandas/plotting/_core.py
Outdated
`**kwds` : optional | ||
y : str or int, optional | ||
Label or position. | ||
If not provided, ``subplots=True`` argument must be passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? What happens if we don't pass subplots=True
and we don't pass a y
argument? Does it raise an error? What does the subplots=True
argument change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This error is raised:
ValueError: pie requires either y column or 'subplots=True'
with subplots=True, pie() returns an array of plots for all columns
pandas/plotting/_core.py
Outdated
|
||
See Also | ||
-------- | ||
:meth:`pandas.Series.plot.pie` : Generate a pie plot for a Serie. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pie plot for a Series
, in plural
pandas/plotting/_core.py
Outdated
Column to plot. | ||
`**kwds` : optional | ||
y : str or int, optional | ||
Label or position. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the Column to plot
part important. What about Label of position indicating the column to plot
?
pandas/plotting/_core.py
Outdated
Examples | ||
-------- | ||
|
||
.. plot:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some text above explaining what is the example about in plain English? Also, perhaps you want to create different plots for different y
values to show how the plot changes when changing the y
argument.
Hello @dim1tri! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on March 16, 2018 at 21:46 Hours UTC |
pandas/plotting/_core.py
Outdated
|
||
A pie plot is a representation of the distribution of numerical data | ||
in a DataFrame column. This function wraps the `matplotlib.pyplot.pie` | ||
function for specified column. If no column reference is passed and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the specified column
pandas/plotting/_core.py
Outdated
|
||
A pie plot is a representation of the distribution of numerical data | ||
in a DataFrame column. This function wraps the `matplotlib.pyplot.pie` | ||
function for specified column. If no column reference is passed and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refer to 'y' here (its the column reference)
pandas/plotting/_core.py
Outdated
y : str or int, optional | ||
Label or position of the column to plot. | ||
If not provided, ``subplots=True`` argument must be passed. | ||
**kwds : optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no ** on kwds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback there is a huge confusion here. @datapythonista said we DO want ** on kwds and they are modifying the validation script to accept it. Now you say we don't want it. Can we make a decision about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback we decided to keep them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback I thought the consensus was to have them. We've got a bug in the script that was validating the opposite, which created some confusion, but in the documentation we've got that they should have the **
in the name.
If there is no final decision, I'd accept both. I think it should be quite easy to use validate_docstrings.py
to detect all the ones that have, or not have them. And we can quickly change all them later on.
pandas/plotting/_core.py
Outdated
in a DataFrame column. This function wraps the `matplotlib.pyplot.pie` | ||
function for specified column. If no column reference is passed and | ||
``subplots`` argument is set to ``True``, an np.array of plots for | ||
all DataFrame columns will be returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all the DataFrame columns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Added some comments
pandas/plotting/_core.py
Outdated
A pie plot is a representation of the distribution of numerical data | ||
in a DataFrame column. This function wraps the `matplotlib.pyplot.pie` | ||
function for specified column. If no column reference is passed and | ||
``subplots`` argument is set to ``True``, an np.array of plots for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use single backticks for 'subplots' (because it is a reference to a parameter)
pandas/plotting/_core.py
Outdated
y : label or position, optional | ||
Column to plot. | ||
`**kwds` : optional | ||
y : str or int, optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit a corner case as well, but in another PR we decide to keep the 'label', as 'str' can actually be too strict on the column name (column names can be other things as strings) ..
pandas/plotting/_core.py
Outdated
Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`. | ||
|
||
Returns | ||
------- | ||
axes : matplotlib.AxesSubplot or np.array of them | ||
axes : matplotlib.AxesSubplot or np.array of them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain here when an array is returned?
pandas/plotting/_core.py
Outdated
|
||
See Also | ||
-------- | ||
:meth:`pandas.Series.plot.pie` : Generate a pie plot for a Series. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave out the :meth:`
part here (the link is automatically made by numpydoc
I would also add the see also to matplotlib.pyplot.pie
pandas/plotting/_core.py
Outdated
|
||
>>> df = pd.DataFrame({'mass': [0.330, 4.87 , 5.97], | ||
... 'radius': [2439.7, 6051.8, 6378.1]}) | ||
>>> plot = df.plot.pie(y='mass', labels=['Mercury', 'Venus', 'Earth']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add an example with the subplots argument?
pandas/plotting/_core.py
Outdated
`**kwds` : optional | ||
y : str or int, optional | ||
Label or position of the column to plot. | ||
If not provided, ``subplots=True`` argument must be passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvement proposal: If not provided, the ``subplots=True`` argument must be passed. In this case, a subplot will be created for every column of the DataFrame
.
pandas/plotting/_core.py
Outdated
|
||
Examples | ||
-------- | ||
In the example below we have a DataFrame with the information about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a matter of style, but I'd say:
Given a DataFrame with information about some planets mass and radius, create a pie plot of their masses:
Because the fact that it is an example can be determined from the section it is in, and the fact that we pass the 'mass' column to the pie
method can be seen in the code itself.
What about another example without specifying the y
argument?
@dim1tri please ping me if you have issues fixing the merge conflicts. |
@dim1tri is there something we can do to help you with this PR? |
* Aspect Ratio * Use index [ci skip]
Codecov Report
@@ Coverage Diff @@
## master #20133 +/- ##
=========================================
Coverage ? 91.72%
=========================================
Files ? 150
Lines ? 49152
Branches ? 0
=========================================
Hits ? 45086
Misses ? 4066
Partials ? 0
Continue to review full report at Codecov.
|
@dim1tri Thanks! |
I have wanted to ask for a while, but never sure where.. Is this documentation page a joke? Is it intentionally trolling? It is, right? |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py pandas.DataFrame.plot.pie
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks: